<?php
defined('BASEPATH') OR exit('No direct script access allowed');
 
class FeedbackSupervisorConfig extends AdminController {

	function __construct() {
		parent::__construct();
		$this -> load ->model("Supervisor_feedback_config_model");		
	}

	function Index() {		
		$this->load->view('admin/FeedbackSupervisorConfig.php');	
	}
	
	function getConfig(){
		$result = $this -> Supervisor_feedback_config_model ->get_list(array("status"=>CommonWhether::Whether[XPHEnum::Value]));
		exit(retJson("返回类型",true,$result));
	}

	function saveConfig(){
		$name=$_POST['name'];
		$this-> Supervisor_feedback_config_model ->query('delete  from db_supervisor_feedback_config',false);
		foreach ($name as $k => $v) {
			$result =$this -> Supervisor_feedback_config_model->get_single(array("name"=>$v,'status'=>CommonStatus::UnDeleted[XPHEnum::Value]));
			if($result){
				exit(retJson($v."已存在",false));
			}
			$this -> Supervisor_feedback_config_model ->add(array("name" =>$v,"status"=>CommonWhether::Whether[XPHEnum::Value],"created"=>time()));
		}		
		exit(retJson("新增类型成功",true));
	}

	function delConfig(){
		$id=$_POST['id'];
		$this -> Supervisor_feedback_config_model->update(array("id"=>$id,"status" =>CommonWhether::Not[XPHEnum::Value]));
		exit(retJson("删除类型成功",true));
	}

}
